# -*- coding: utf-8 -*-
# @Organization  : asiainfo
# @Author        : 周伟东
# @Time          : 2021/1/27 14:40
# @Function      : AM 操作
import logging

from app.dao import Session
from app.dao.base_dao import BaseDao
from app.models import AMOS


class AMDao(BaseDao):
    def get_os(self):
        """
        desc:获取所有的操作系统信息
        """
        session = Session()
        try:
            os_list = session.query(AMOS.ID, AMOS.OS_NAME).all()

            os_dict = {}
            for os in os_list:
                os_dict[os.OS_NAME] = os.ID

            # logging.info(os_dict)
            return os_dict
        except Exception as e:
            logging.error("查找os消息失败", e)
        finally:
            session.close()


amDao = AMDao()
